<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // const str = '10000000000'
    const str = '100000000000'
    // 每三位逗号分隔
    // \b单词边界，\B非单词边界
    console.log(str.replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'));
    console.log(str.replace(/\B(?=(\d{3})+$)/g, ','));
    console.log((+str).toLocaleString());
  </script>
</body>
</html>